# Contributor: Jordan Christiansen <xordspar0@gmail.com>
# Maintainer: Jordan Christiansen <xordspar0@gmail.com>
pkgname=sanoid
pkgver=2.1.0
pkgrel=0
pkgdesc="Policy-driven snapshot management and replication tools"
url="https://github.com/jimsalterjrs/sanoid"
arch="noarch"
license="GPL-3.0-only"
depends="procps perl-config-inifiles perl-capture-tiny"
_depends_syncoid="procps perl-capture-tiny pv gzip lzop mbuffer"
checkdepends="bash"
subpackages="syncoid"
source="$pkgname-$pkgver.tar.gz::https://github.com/jimsalterjrs/sanoid/archive/v$pkgver.tar.gz
	$pkgname.cron
	$pkgname-prune.cron"

check() {
	tests/run-tests.sh
}

package() {
	install -Dm775 sanoid "$pkgdir"/usr/bin/sanoid
	install -Dm775 findoid "$pkgdir"/usr/bin/findoid

	install -Dm644 sanoid.conf "$pkgdir"/etc/sanoid/sanoid.conf
	install -Dm644 sanoid.defaults.conf "$pkgdir"/etc/sanoid/sanoid.defaults.conf

	install -Dm755 "$srcdir"/sanoid.cron "$pkgdir"/etc/periodic/15min/sanoid
	install -Dm755 "$srcdir"/sanoid-prune.cron "$pkgdir"/etc/periodic/15min/sanoid-prune
}

syncoid() {
	depends="$_depends_syncoid"
	install -Dm775 "$builddir"/syncoid "$subpkgdir"/usr/bin/syncoid
}

sha512sums="
d5f3b85f745b5776ae602630a6a8c317612fe4fc3b33f14582aa71fabd25077c26da2fcb7501b7b9794f8a577b798e8676634dcaf24d5ecb39db453dbb769347  sanoid-2.1.0.tar.gz
9e9a45f19c16dee01581701a22a360bf45a594e99229e99da0af04c8ac5609d75e3721816f8b58f9c4058a57bd9538ab70fa09a697376dac2ced953e04052ea5  sanoid.cron
47f003f0fdbd8cd1977a449f29a16ea1227eb3d55e693a1badfa3db603158415754b073b7bd7ce4e1f0e6c30e17c6137cdc2a652e48d39802d35ad48173273a0  sanoid-prune.cron
"
